package com.group525.cloudef.mapper.doctor;

import com.group525.cloudef.Dao.doctor.UserInfo;
import com.group525.cloudef.entity.doctor.DUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.group525.cloudef.entity.user.UImage;
import com.group525.cloudef.entity.user.UReport;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author group525
 * @since 2023-04-19
 */
@Mapper
public interface DUserMapper extends BaseMapper<DUser> {
//    @Select("select * from d_user where jobNumber=#{jobNumber}")
    DUser login(@Param("jobNumber") String jobNumber);

    @Select("select * from d_user where jobNumber=#{jobNumber}")
    UserInfo info(String jobNumber);

    @Select("SELECT COLUMN_NAME, COLUMN_COMMENT FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'd_user';")
    List<Map<String, Object>> getUserInfoZh();

    @Select("select * from u_report")
    List<UReport> reportList();
    @Select("select name from d_user where id=#{id}")
    String getDocName(Long id);
    @Select("select name from u_user where id=#{id}")
    String getPatientName(Long id);
    @Select("select gender from u_user where id=#{id}")
    String getPatientGender(Long id);
    @Select("select age from u_user where id=#{id}")
    String getPatientAge(Long id);
    @Select("select * from u_report where report_no=#{reportNo}")
    UReport getDiseaseInfo(Long reportNo);
    @Select("select image from u_image where report_no=#{reportNo}")
    List<UImage> getImage(Long reportNo);
    @Update("update u_report set disease_name=#{diseaseName}, check_intro=#{checkIntro}, image_info=#{imageInfo}," +
            "diagnose=#{diagnose}, update_time=#{updateTime} where report_no=#{reportNo}")
    Integer updateReport(String diseaseName, String checkIntro, String imageInfo, String diagnose, Date updateTime, Long reportNo);

    @Select("select title from a_notification where receiver=1")
    List<String> getTitle();
    @Select("select content from a_notification where title=#{title}")
    String getContent(String title);
}
